﻿using System;
using System.Collections.Generic;
using System.Text;
using ECC_EXT_Entity;
using NHibernate;
using NHibernate.Criterion;

namespace ECC_EXT_DAO.Dao
{
    public class MerchandiseDao : DaoBase
    {

        public void SaveOrUpdate(MerchandiseEntity _merchandiseEntity)
        {
            using (ISession session = this.SessionFactory.OpenSession())
            {
                session.BeginTransaction();
                session.SaveOrUpdate(_merchandiseEntity);
                session.Transaction.Commit();
            }
        }

        public IList<MerchandiseEntity> GetByAnnotationId(long _annotationId)
        {

            using (ISession session = this.SessionFactory.OpenSession())
            {
                ICriteria criteria =
                    session.CreateCriteria<MerchandiseEntity>();
                //if (_offAnnotationEntity.)
                criteria.Add(Restrictions.Eq("AnnotationID", _annotationId));
                //criteria.Add(Restrictions.Eq("Type", _offAnnotationEntity.Type));
                return
                criteria.List<MerchandiseEntity>();
            }
        
        }
    }
}
